package com.tsingteng.cosfun.ui.cosfun.presenter;

import com.tsingteng.cosfun.bean.BaseDataBean;
import com.tsingteng.cosfun.bean.PersonBean;
import com.tsingteng.cosfun.bean.VideoSignBean;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;
import com.tsingteng.cosfun.ui.cosfun.contract.FeedBackContract;
import com.tsingteng.cosfun.ui.cosfun.contract.PersonEditContract;
import com.tsingteng.cosfun.ui.cosfun.imodel.FeedBackModel;
import com.tsingteng.cosfun.ui.cosfun.imodel.PersonEditModel;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class FeedbackPresenter extends BasePresenter<FeedBackContract.IfeedBackView> implements FeedBackContract.IfeedBack {

    FeedBackModel feedBackModel = null;
    FeedBackContract.IfeedBackView ifeedBackView = null;

    public FeedbackPresenter(FeedBackContract.IfeedBackView ifeedBackView) {
        this.feedBackModel = new FeedBackModel();
        this.ifeedBackView = ifeedBackView;
    }


    @Override
    public void feedback(String content, String img, String phone, String sign) {
        ifeedBackView.showLoading("");
        Callback<BaseDataBean<PersonBean>> callback = new Callback<BaseDataBean<PersonBean>>() {
            @Override
            public void onResponse(Call<BaseDataBean<PersonBean>> call, Response<BaseDataBean<PersonBean>> response) {
                ifeedBackView.hideLoading();
                ifeedBackView.onSuccess(response.body());
            }

            @Override
            public void onFailure(Call<BaseDataBean<PersonBean>> call, Throwable t) {
                ifeedBackView.hideLoading();
            }
        };
        feedBackModel.feedbak(content, img, phone, sign, callback);
    }

    @Override
    public void getSignTureData(String typ) {
        Callback<BaseDataBean<VideoSignBean>> callback = new Callback<BaseDataBean<VideoSignBean>>() {
            @Override
            public void onResponse(Call<BaseDataBean<VideoSignBean>> call, Response<BaseDataBean<VideoSignBean>> response) {
                ifeedBackView.UploadVideo(response.body().data);
            }

            @Override
            public void onFailure(Call<BaseDataBean<VideoSignBean>> call, Throwable t) {
            }


        };
        feedBackModel.getSignaTure(typ, callback);
    }

}
